package com.yicong.ants.ui.order;

import android.view.View;

import com.cchao.simplelib.core.GsonUtil;
import com.cchao.simplelib.core.UiHelper;
import com.cchao.simplelib.ui.activity.BaseTitleBarActivity;
import com.yicong.ants.Constants;
import com.yicong.ants.R;
import com.yicong.ants.bean.scenic.HomeRecItem;
import com.yicong.ants.databinding.PayProductActivityBinding;

/**
 * 支付页
 *
 * @author cchao
 * @version 2019-05-28.
 */
public class PayProductActivity extends BaseTitleBarActivity<PayProductActivityBinding> implements View.OnClickListener {

    HomeRecItem mHomeRecItem;

    @Override
    protected int getLayout() {
        return R.layout.pay_product_activity;
    }

    @Override
    protected void initEventAndData() {
        setTitleText("付款至");
        mHomeRecItem = GsonUtil.fromJson(getIntent().getStringExtra(Constants.Extra.JSON), HomeRecItem.class);
        mDataBind.setBean(mHomeRecItem);
        mDataBind.setClick(this);
    }

    @Override
    protected void onLoadData() {

    }

    void changeSelect() {
        mDataBind.radioDiscount.toggle();
        boolean checked = mDataBind.radioDiscount.isChecked();
        UiHelper.setVisibleElseGone(mDataBind.noDiscountField, !checked);
        UiHelper.setVisibleElseGone(mDataBind.discountField, checked);
        if (checked) {
            mDataBind.cash.setText("234");
            mDataBind.discount.setText("122224");
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.discount_select_field:
                changeSelect();
                break;
        }
    }
}
